package com.shujia.override;

import org.junit.Test;

public class PersonTest {

    @Test
    public void test1() {
        /*
        如果调用的方法没有被重写，执行父类的方法
        如果调用的方法被子类重写，调用的是子类的方法
         */
        Student student = new Student();
        student.setName("张三");
        student.setAge(18);
        student.info();

        Teacher teacher = new Teacher();
        teacher.setName("李四");
        teacher.setAge(25);
        teacher.info();
    }


    public static void main(String[] args) {
        Student student = new Student();
        student.setName("张三");
        student.setAge(18);
        student.info();

        Teacher teacher = new Teacher();
        teacher.setName("李四");
        teacher.setAge(25);
        teacher.info();

    }

}
